layui.use('form', function() {
    var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功

    form.on('select', function (data) {
        resState =(data.value);

        //但是，如果你的HTML是动态生成的，自动渲染就会失效
        //因此你需要在相应的地方，执行下述方法来手动渲染，跟这类似的还有 element.init();
        form.render();

        if(resState=="录用"){
            //alert("进来了")
            //获取当前日期
            let myDate = new Date();

            //赋值给时间
            $("#endMianTime").val(myDate.toLocaleDateString());
            //alert(myDate.toLocaleDateString())
            //同时将评价的只读取消
            $("#endMianAppraise").attr("readOnly",false);
            $("#tt1").find("div").find("div").find("div").find("dl").find("dd").eq(1).attr("class","layui-this");
            $("#tt1").find("div").find("div").find("div").find("dl").find("dd").eq(2).attr("class","layui-this");
        }
        if(resState=="存档"){

            $("#endMianTime").val(null);
            $("#endMianAppraise").attr("readOnly",true);
            $("#tt1").find("div").find("div").find("div").find("dl").find("dd").eq(1).attr("class","layui-this");
            $("#tt1").find("div").find("div").find("div").find("dl").find("dd").eq(2).attr("class","layui-this");

        }

    });

});

function fanhui() {
    window.location.href="/录用管理"
}

function jiazai() {
    let t = $("#tt1").find("div").find("div").find("div").find("div").find("input").val()

    let t1 = $("#tt1").find("div").find("div").find("div").find("dl").find("dd").eq(0);
    let t2 = $("#tt1").find("div").find("div").find("div").find("dl").find("dd").eq(1);
    let t3 = $("#tt1").find("div").find("div").find("div").find("dl").find("dd").eq(2);
    let t4 = $("#tt1").find("div").find("div").find("div").find("dl").find("dd").eq(3);
    let t5 = $("#tt1").find("div").find("div").find("div").find("dl").find("dd").eq(4);

    if (t=="建议录用"){
        t2.attr("class","layui-this");
        t3.attr("class","layui-this");
    }
}

function save2(interviewId) {
    let status = $("#tt1").find("div").find("div").find("div").find("div").find("input").val();
    let oneInterviewer = $("#firstMianPeople").val().trim();
    let oneTime =$("#firstMianTime").val().trim();
    let oneOpinion=$("#firstMianAppraise").val().trim();
    let twoInterviewer=$("#secondMianPeople").val().trim();
    let twoTime=$("#secondMianTime").val().trim();
    let twoOpinion=$("#secondMianAppraise").val().trim();
    let threeInterviewer=$("#thirdMianPeople").val().trim();
    let threeTime=$("#thirdMianTime").val().trim();
    let threeOpinion=$("#thirdMianAppraise").val().trim();
    let endMianTime=$("#endMianTime").val().trim();
    let endMianAppraise=$("#endMianAppraise").val().trim();

    if (status=="建议录用"){
        if (endMianTime==""||endMianTime==null){
            alert("未填写决议时间！")
            return;
        }
        if (endMianAppraise==""||endMianAppraise==null){
            alert("未填写录用决议！")
            return;
        }

    }else if (status=="存档"){
        endMianTime=null;
        endMianAppraise=null;
    }

    jsonA={
        interviewId:interviewId,
        status:status,
        endTime:endMianTime,
        endOpinion:endMianAppraise
    }
    $.ajaxSettings.async=false;
    $.getJSON("/save21",jsonA,function (data) {
        if (data > 0){
            alert("保存成功！")
            window.location.href = "/录用管理"
        }else {
            alert("保存失败！")
        }

    })
    $.ajaxSettings.async=true;
}